#include <bits/stdc++.h>
// 2025/01/22
// tag: 
// Author: Zhang Muen
using namespace std;

int n, m, num[100001];
int64_t ans;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> num[i];
    sort(num + 1, num + n + 1);
    for (int i = 1; i <= m; i++)
    {
        int x;
        cin >> x;
        int a = lower_bound(num + 1, num + n + 1, x) - num;
        int m = INT_MAX;
        if (a > n)
            m = abs(num[n] - x);
        else
            if (a == 1)
                m = abs(num[1] - x);
            else
                m = min(abs(num[a - 1] - x), abs(num[a] - x));
        ans += m;
    }
    cout << ans;
    return 0;
}